<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp" %>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>公司</title>
    <script type="text/javascript">
	    var mainform;
	    var viewType = "${viewType}";
        $(function ()
        {        
            mainform=$("#mainform");
            
            mainform.ligerForm();
            
            if(viewType=="modify"){
            	 $("#cpnId").attr("readonly", "readonly").removeAttr("validate");
            }
            
            if(viewType=="detail"){
            	$("input,select,textarea",mainform).attr("readonly", "readonly");
            }else{
                $.metadata.setType("attr", "validate");
                LG.validate(mainform);
            }
            
            LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);

        });  
        
        function save(){
            LG.submitForm(mainform, function (result) {
            	if(typeof(result)=="string"){
            		result=eval("("+result+")");
            	}
                if (!result.success) {
                    LG.showError('错误:' + data.message);
                }
                else { 
                    LG.showSuccess('保存成功', function () { 
                       LG.callParent("companyList");
                    });
                }
            });
        }
        function cancel(){
            var win = window.parent || window;
            if(win.dialog){
            	win.dialog.close();
            }
        }
    </script>
</head>

<body style="padding:10px">
    <form name="mainform" method="post"  id="mainform" action="${ctx }/company/save">
        <input type="hidden" name="viewType" value="${viewType}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 100%;">
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">公司代码:</td>
                <td align="left" class="l-table-edit-td" style="width:80px" >
                	<input type="text"  name="cpnId" id="cpnId" value="${command.cpnId }" ltype="text" validate="{required:true,minlength:2,maxlength:50,notnull:true,remote:'${ctx}/company/checkCpnId?oldCpnId=${command.cpnId}'}"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">公司名称:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
	               <input type="text"  name="cpnName" id="cpnName" value="${command.cpnName }" ltype="text" validate="{required:true,minlength:2,maxlength:50,notnull:true}"/>
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">公司代号:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
                	<input type="text"  name="cpnCode" id="cpnCode" value="${command.cpnCode }" ltype="text" validate="{required:true,minlength:2,maxlength:50,notnull:true}"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">英文名称:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
                	<input type="text" name="cpnNameE" id="cpnNameE" value="${command.cpnNameE }" ltype="text" validate="{required:true,notnull:true}"/>
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td">启用:</td>
                <td align="left" class="l-table-edit-td" style="width:160px" >
                	<c:choose>
                		<c:when test="${command.isEnable eq 'F' }">
                			<input id="isEnable" type="checkbox" name="isEnable" value="F" onchange="changeTnf(this)"/> 
                		</c:when>
                		<c:otherwise>
                			<input id="isEnable" type="checkbox" name="isEnable" value="T" checked="checked"  onchange="changeTnf(this)"/> 
                		</c:otherwise>
                	</c:choose>
                </td>
                <td align="left"></td>
                <td align="left" class="l-table-edit-td" valign="top"></td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td">备注:</td>
                <td align="left" class="l-table-edit-td"> 
                <textarea cols="100" rows="3" class="l-textarea" id="remark" name="remark" style="width:400px">${command.remark}</textarea>
                </td> <td align="left"></td>
           </tr>
           <tr>
                <td align="left" class="l-table-edit-td" valign="top">建档人:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">${command.userCre }</td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">修改人:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">${command.userUpd }</td>
                <td align="left"></td>
           </tr>
        </table>
    </form>
</body>
</html>
